package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class BackslashesInRegularExpressions {
	public static void main(String[] argv) {
		String rep = "a\\\\b";
		String input = "> XYZ <=> ABC <";
		Pattern pattern = Pattern.compile("ABC|XYZ");
		Matcher matcher = pattern.matcher(input);

		System.out.println(matcher.replaceFirst(rep));
		System.out.println(matcher.replaceAll(rep));

		rep = "\\\\r\\\\n";
		input = "line 1\nline 2\nline 3\n";
		pattern = Pattern.compile("\\n");
		matcher = pattern.matcher(input);

		System.out.println("");
		System.out.println("之前:");
		System.out.println(input);

		System.out.println("之后:");
		System.out.println(matcher.replaceAll(rep));
	}
}
